<template>
	<view class="home_header">
		<navigator url="/pagesA/homeMessage/index" class="vchcClass">
			<view class="message" @click="toPath('notice')">
				<!-- 				<u-icon name="bell" size="60"></u-icon>
 -->
				<u-image width="44rpx" height="44rpx" :src="message"></u-image>
				<u-badge :is-dot="true" :count="2" is-center></u-badge>
			</view>
		</navigator>

		<view class="home_search" @click="toPath('homeSearch')">
			<u-icon name="search" color="#999" size="32" class="icon"></u-icon>
			<input class="input" type="text" :placeholder="placeholder" />


		</view>

		<view @click="scan" class="vchcClass">
			<!--      <u-icon name="scan" size="60"></u-icon>
 -->
			<u-image width="44rpx" height="44rpx" :src="code"></u-image>

		</view>

	</view>
</template>


<script>
	export default {
		data() {
			return {
				placeholder: '请输入设备名称或MAC地址',
				message: '../../../static/images/index/message.png',
				code: '../../../static/images/index/code.png',

			};
		},
		props: {
			isSystemDot: {
				type: Boolean,
				default: false,
			},
			isUserDot: {
				type: Boolean,
				default: false,
			},
		},
		methods: {
			toPath(path) {
				console.log('topath====', path)
				if (uni.getStorageSync("token")) {
					uni.navigateTo({
						url: "/pages/login/login",
					});
				} else if (path == 'homeSearch') {
					uni.navigateTo({
						url: '/pagesA/homeSearch/index?placeholder=' + this.placeholder
					})
				} else if (path == 'notice') {
					this.$u.route('pages/notice/index')
				} else {
					uni.reLaunch({
						url: "/pages/location/index",
					});
				}
			},
			//调用二维码
			scan() {
				uni.scanCode({
					success: (res) => {
						console.log("条码类型：" + res.scanType);
						console.log("条码内容：" + res.result);
						uni.navigateTo({
							url: "/pages/deviceDetail/deviceDetail?content=" + res.result,
						});
					},
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.vchcClass {
		width: 60rpx;
		height: 60rpx;
		margin: 0 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.address {
		color: #FFFFFF;
		font-size: 46rpx;
		margin: 0 6rpx 0 20rpx;
	}

	.message {
		position: relative;
		width: 44rpx;
		height: 44rpx;
	}

	.number {
		position: absolute;
		top: 4rpx;
		right: 16rpx;
		background: #f2f2f2;
		color: #FFFFFF;
		border-radius: 50%;
		width: 14rpx;
		height: 14rpx;
	}

	.home_header {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 100rpx;
		// background: linear-gradient(0deg, #2396ff 20%, #22a3ff 80%);
		background: #22a3ff;
		z-index: 100;

		.text {
			width: 60rpx;
			height: 30rpx;
			font-size: 32rpx;
			font-weight: bold;
			color: #FFFFFF;
			white-space: nowrap;
			line-height: 32rpx;
			margin-right: 24rpx;
		}

		.home_search {
			// width: 430rpx;
			flex: 1;
			margin: 0 20rpx;
			height: 68rpx;
			background: #FFFFFF;
			border-radius: 10rpx;
			display: flex;
			align-items: center;

			.search {
				color: #FFFFFF;
				font-size: 38rpx;
				margin-left: 20rpx;
				margin-right: 16rpx;
			}

			.input {
				height: 68rpx;
				font-size: 28rpx;
				width: 88%;
			}

			.icon {
				margin-left: 20rpx;
				margin-right: 12rpx;
			}
		}

		.comment {
			margin: 0 20rpx;
			font-size: 52rpx;
			color: #FFFFFF;
		}

		.sweep {
			font-size: 42rpx;
			color: #FFFFFF;
		}
	}
</style>
